﻿using System;
using System.Collections.Generic;
using System.Xml;
using IURIP;
using URIP.Tool;

namespace URIP.Factory
{
    /// <summary>
    /// Factory to create propagator
    /// </summary>
    public class PropagatorFactory
    {
        static PropagatorFactory()
        {
            InitPropagators();
        }
        /// <summary>
        /// The propagator defined in the system
        /// </summary>
        private static Dictionary<string, Type> m_propagators = new Dictionary<string, Type>();

        /// <summary>
        /// Initialize all default propagators into a container.
        /// </summary>
        private static void InitPropagators()
        {
            //@@ add all default propagator here
        }
        /// <summary>
        /// Get a specified propagator from the setting
        /// </summary>
        /// <param name="node"></param>
        /// <param name="task"></param>
        /// <returns></returns>
        public static IPropagator GetPropagator(XmlNode node, ITask task)
        {
            var res = Util.GetObjectForFactory<IPropagator>(m_propagators, node, task);
            if (res != null)
            {
                res.InitByConfiguration(node);
            }
            return res;
        }
    }
}
